package com.yigo.toc.infra.repo.converter;

import com.yigo.toc.domain.to.aggregateroot.TradeOrder;
import com.yigo.toc.domain.to.entity.TradeOrderAddress;
import com.yigo.toc.domain.to.entity.TradeOrderDetail;
import com.yigo.toc.infra.repo.dataobject.TocOrderAddressPO;
import com.yigo.toc.infra.repo.dataobject.TocOrderHeadPO;
import com.yigo.toc.infra.repo.dataobject.TocOrderLinePO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * @author chenzl
 */
@Mapper
public interface TcDmo2PoConverter {
    TcDmo2PoConverter INSTANCE = Mappers.getMapper(TcDmo2PoConverter.class);

    TocOrderHeadPO toPO(TradeOrder source);

    @Mapping(target = "productCode", source = "product.productCode")
    @Mapping(target = "productName", source = "product.productName")
    TocOrderLinePO toPO(TradeOrderDetail source);

    TocOrderAddressPO toPO(TradeOrderAddress source);

}
